import { useState, useEffect, useRef } from 'react';
 
function useResize(callback) {
  const [size, setSize] = useState({ width: window.innerWidth, height: window.innerHeight });
  const handleResize = () => {
    setSize({ width: window.innerWidth, height: window.innerHeight });
    callback && callback(size);
  };
 
  useEffect(() => {
    window.addEventListener('resize', handleResize);
    return () => window.removeEventListener('resize', handleResize);
  }, []);
 
  return size;
}
export default useResize